home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / WindowClickEditor.cpp < prev    next >
Text File  |  1997-02-20  |  7KB  |  226 lines

  1. /*
  2.  *  File:       WindowClickEditor.h
  3.  *  Summary:       A view that knows how to edit a TWindow's clicking info.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->    12/24/96    JDJ        Created
  12.  */
  13.  
  14. #include "WindowClickEditor.h"
  15.  
  16. #include <ZTextBox.h>
  17.  
  18.  
  19. // ===================================================================================
  20. //    class CEditWindowClickCommand
  21. // ===================================================================================
  22.  
  23. //---------------------------------------------------------------
  24. //
  25. // CEditWindowClickCommand::~CEditWindowClickCommand
  26. //
  27. //---------------------------------------------------------------
  28. CEditWindowClickCommand::~CEditWindowClickCommand()
  29. {
  30. }
  31.  
  32.  
  33. //---------------------------------------------------------------
  34. //
  35. // CEditWindowClickCommand::CEditWindowClickCommand
  36. //
  37. //---------------------------------------------------------------
  38. CEditWindowClickCommand::CEditWindowClickCommand(TWindow* pane, const SWindowInfo& oldInfo, const SWindowInfo& newInfo) : Inherited(pane, oldInfo, newInfo)
  39. {
  40. }
  41.  
  42.  
  43. //---------------------------------------------------------------
  44. //
  45. // CEditWindowClickCommand::UpdatePane
  46. //
  47. //---------------------------------------------------------------
  48. void CEditWindowClickCommand::UpdatePane(const SWindowInfo& newInfo)
  49. {
  50.     SWindowInfo info = mPane->GetInfo();
  51.     
  52.     info.attr.layer          = newInfo.attr.layer;
  53.     info.attr.handleClicks   = newInfo.attr.handleClicks;
  54.     info.attr.targetable     = newInfo.attr.targetable;
  55.     info.attr.clickThrough   = newInfo.attr.clickThrough;
  56.     info.attr.getSelectClick = newInfo.attr.getSelectClick;
  57.     info.attr.hideOnSuspend  = newInfo.attr.hideOnSuspend;
  58.  
  59.     mPane->SetInfo(info);
  60. }
  61.  
  62. #pragma mark -
  63.  
  64. // ===================================================================================
  65. //    CWindowClickEditor
  66. // ===================================================================================
  67.  
  68. static TReanimatorRegister<CWindowClickEditor> sWindowClickEditorRegistrar;
  69.  
  70. //---------------------------------------------------------------
  71. //
  72. // CWindowClickEditor::~CWindowClickEditor
  73. //
  74. //---------------------------------------------------------------
  75. CWindowClickEditor::~CWindowClickEditor()
  76. {
  77. }
  78.  
  79.  
  80. //---------------------------------------------------------------
  81. //
  82. // CWindowClickEditor::CWindowClickEditor
  83. //
  84. //---------------------------------------------------------------
  85. CWindowClickEditor::CWindowClickEditor(TView* superView) : Inherited(superView)
  86. {
  87. }
  88.  
  89.  
  90. //---------------------------------------------------------------
  91. //
  92. // CWindowClickEditor::Create                            [static]
  93. //
  94. //---------------------------------------------------------------
  95. MReanimatable* CWindowClickEditor::Create(MReanimatable* parent)
  96. {
  97.     return new CWindowClickEditor(dynamic_cast<TView*>(parent));
  98. }
  99.  
  100.  
  101. //---------------------------------------------------------------
  102. //
  103. // CWindowClickEditor::OnReanimated        
  104. //
  105. //---------------------------------------------------------------
  106. void CWindowClickEditor::OnReanimated()
  107. {
  108.     Inherited::OnReanimated();
  109.     
  110.     TControl* control = nil;
  111.         
  112.     control = dynamic_cast<TControl*>(this->FindSubPane("Layer"));
  113.     control->AddListener(this);
  114. }
  115.  
  116.  
  117. //---------------------------------------------------------------
  118. //
  119. // CWindowClickEditor::GetEditorInfo        
  120. //
  121. //---------------------------------------------------------------
  122. SWindowInfo CWindowClickEditor::GetEditorInfo() const
  123. {
  124.     SWindowInfo info;
  125.     
  126.     TControl* control = nil;
  127.         
  128.     control = dynamic_cast<TControl*>(this->FindSubPane("Layer"));
  129.     if (control->GetValue() == 1)
  130.         info.attr.layer = kModalLayer;
  131.     else if (control->GetValue() == 2)
  132.         info.attr.layer = kFloatingLayer;
  133.     else
  134.         info.attr.layer = kRegularLayer;
  135.     
  136.     control = dynamic_cast<TControl*>(this->FindSubPane("Handle Clicks"));
  137.     info.attr.handleClicks = control->GetValue();
  138.     
  139.     control = dynamic_cast<TControl*>(this->FindSubPane("Targetable"));
  140.     info.attr.targetable = control->GetValue();
  141.     
  142.     control = dynamic_cast<TControl*>(this->FindSubPane("Get Select Click"));
  143.     info.attr.getSelectClick = control->GetValue();
  144.     
  145.     control = dynamic_cast<TControl*>(this->FindSubPane("Click Through"));
  146.     info.attr.clickThrough = control->GetValue();
  147.     
  148.     control = dynamic_cast<TControl*>(this->FindSubPane("Hide on Suspend"));
  149.     info.attr.hideOnSuspend = control->GetValue();
  150.     
  151.     return info;
  152. }
  153.  
  154.  
  155. //---------------------------------------------------------------
  156. //
  157. // CWindowClickEditor::SetEditorInfo
  158. //
  159. //---------------------------------------------------------------
  160. void CWindowClickEditor::SetEditorInfo(const SWindowInfo& info)
  161. {
  162.     TControl* control = nil;
  163.     
  164.     control = dynamic_cast<TControl*>(this->FindSubPane("Layer"));
  165.     if (info.attr.layer == kModalLayer)
  166.         control->SetValue(1);
  167.     else if (info.attr.layer == kFloatingLayer)
  168.         control->SetValue(2);
  169.     else
  170.         control->SetValue(3);
  171.     
  172.     control = dynamic_cast<TControl*>(this->FindSubPane("Handle Clicks"));
  173.     control->SetValue(info.attr.handleClicks);
  174.     
  175.     control = dynamic_cast<TControl*>(this->FindSubPane("Targetable"));
  176.     control->SetValue(info.attr.targetable);
  177.     control->HandleEnable(info.attr.layer != kFloatingLayer, kRedraw);
  178.     
  179.     control = dynamic_cast<TControl*>(this->FindSubPane("Get Select Click"));
  180.     control->SetValue(info.attr.getSelectClick);
  181.     
  182.     control = dynamic_cast<TControl*>(this->FindSubPane("Click Through"));
  183.     control->SetValue(info.attr.clickThrough);
  184.     
  185.     control = dynamic_cast<TControl*>(this->FindSubPane("Hide on Suspend"));
  186.     control->SetValue(info.attr.hideOnSuspend);
  187. }
  188.  
  189.  
  190. //---------------------------------------------------------------
  191. //
  192. // CWindowClickEditor::OnBroadcast (SControlMessage)
  193. //
  194. //---------------------------------------------------------------
  195. void CWindowClickEditor::OnBroadcast(const SControlMessage& message)
  196. {
  197.     SWindowInfo info = this->GetEditorInfo();
  198.     
  199.     switch (message.value) {
  200.         case 1:                                        // Modal
  201.             info.attr.layer         = kModalLayer;
  202.             info.attr.targetable    = true;
  203.             info.attr.hideOnSuspend = false;
  204.             break;
  205.             
  206.         case 2:                                        // Floating
  207.             info.attr.layer         = kFloatingLayer;
  208.             info.attr.targetable    = false;
  209.             info.attr.hideOnSuspend = true;
  210.             break;
  211.     
  212.         case 3:                                        // Regular
  213.             info.attr.layer         = kRegularLayer;
  214.             info.attr.targetable    = true;
  215.             info.attr.hideOnSuspend = false;
  216.             break;
  217.     
  218.         default:
  219.             DEBUGSTR("Bogus value (%d) in CWindowClickEditor::OnBroadcast", message.value);
  220.     }
  221.  
  222.     this->SetEditorInfo(info);
  223. }
  224.  
  225.  
  226.